{% extends 'index.html' %}
{% block head-js %}
    <script src="/static/plugins/ckeditor/ckeditor.js"></script>
{% endblock %}
{% block page-container %}
    <div class="new-article">
        {% if new_article_obj %}
            <h3>文章<{{ new_article_obj.title }}>已发布，<a href="{% url 'article_detail' new_article_obj.id %}">点我查看</a></h3>
        {% else %}
            <!--传多媒体等类型数据加上  enctype="multipart/form-data"-->
            <form enctype="multipart/form-data" method="post" action="{% url 'new_article' %}">{% csrf_token %}
            <!--文章标题-->
            <input name="title" type="text" class="form-control" placeholder="文章标题">
            {#{{ category_list }}#}
            <select name="categroy_id" class="form-control">
                {% for category in category_list %}
                    <option value="{{ category.id }}">{{ category.name }}</option>
                {% endfor %}
            </select>
            <input name="summary" type="text" class="form-control" placeholder="一句话文章中心思想">
            <input type="file" name="head_img">必选文章标题图片
            <textarea id="ck-editor" name="content" class="form-control" rows="3"></textarea>

            <br/>
            <!--注意这里不能是button pull-right表示右移-->
            <button type="submit" class="btn btn-success pull-right">提交</button>
        </form>
        {% endif %}
    </div>
{% endblock %}

{% block bootom-js %}
    <script>
        CKEDITOR.replace( 'ck-editor' );
        CKEDITOR.editorConfig = function( config ) {
            //config.language = 'es';
            config.uiColor = '#F7B42C';
            config.height = 500;
            config.toolbarCanCollapse = true;
    };
    </script>
{% endblock %}